<template>
	<view class="content">
		<view class="list-wrapper">
			<view class="item u-f-jsb">
				<view>车牌号</view>
				<view>{{carinfo.carNo}}</view>
			</view>
			<view class="item u-f-jsb">
				<view>VIN码</view>
				<view>{{carinfo.vinCode}}</view>
			</view>
			<view class="item u-f-jsb">
				<view>生产日期</view>
				<view>{{carinfo.productTime}}</view>
			</view>
			<view class="item u-f-jsb">
				<view>常驻位置</view>
				<view>{{carinfo.address}}</view>
			</view>
			<view class="item">
				<view>行驶证照片</view>
				<image class="license" v-for="(item,index) in attachments" :key="index" @tap="previewImg(index)" :src="item.link" mode="widthFix"></image>
			</view>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				attachments: []
			}
		},
		computed: {
			carinfo() {
				return this.$store.state.carinfo
			}
		},
		onLoad() {
			this.getAttachments()
		},
		methods: {
			codeChange(e) {
				console.log(e);
				this.showCodeDialog = false
			},
			getAttachments() {
				this.$http({
					url: this.$api.systemUrl + 'attachment/listByIdsAndFileType',
					method: 'get',
					data: {
						fileType: '0',
						ids: [this.carinfo.id],
					},
					loading: 0
				}).then(res => {
					this.attachments = res.data
				})
			},
			previewImg(index) {
				let urls = this.attachments.map(item => item.link)
				uni.previewImage({
					current: urls[index],
					urls: urls
				})
			}
		}
	}
</script>

<style lang="scss">
	.list-wrapper {
		padding: 0 30rpx;
		background: #fff;
		view {
			font-size: 28rpx;
			color: #333333;
		}
		.item {
			min-height: 92rpx;
			background: #fff;
			line-height: 92rpx;
			
			>view:first-child {
				width: 150rpx;
				flex-shrink: 0;
			}
			
			>view:nth-child(2) {
				text-align: right;
			}
			
			&:not(:last-child) {
				border-bottom: 1rpx solid #eee;
			}
		}
		.license {
			display: block;
			width: 700rpx;
			height: 460rpx;
			margin: 30rpx auto;
		}
	}
</style>
